/**
 * 
 */
$(function () {	
	

	
	/*初始化jqgrid*/
	$("#list_viewTask").jqGrid({
	    url:'data/index.json',
	    datatype: 'json',
	    mtype: 'GET',
	    colNames:['序号','上级计划','关联客户','要求完成','执行人','进度','计划状态','结果责任','创建人'],
	    colModel :[
	   	   		{name:'id',index:'id',align:"right"},
		   		{name:'super',index:'super',editable:true,editrules:{required:true},align:"right"}, 
		   		{name:'custom',index:'custom',editable:true,align:"right"},
		   		{name:'endtime',index:'endtime', align:"right",editable:true},
		   		{name:'executer',index:'executer',  align:"right",editable:true},		
		   		{name:'progress',index:'progress', align:"right",editable:true}	,
		   		{name:'state',index:'state', align:"right",editable:true}	,
		   		{name:'result',index:'result', align:"right",editable:true}	,
		   		{name:'creater',index:'creater', align:"right",editable:true}	,
		   		
		   		
		   	],
	    pager: '#pager_viewTask',
	    rowNum:10,
	    rowList:[10,20,30],
	    sortname: 'sequence',
	    sortorder: 'desc',
	    viewrecords: true,
	    width:$(".ui-layout-center").width()-245,
	    gridview: true,
	    toolbar:[true,"top"],
	    caption: '个人工作台',
	    multiselect: true
	  }); 
	
	
	
	$("#t_list_viewTask").html('<div id="t_list_viewTask_left" class="ui-userdata ui-state-default"></div>');
	
	jQuery("#list_viewTask")
	.jqGrid('navGrid','#t_list_viewTask',{edit:false,add:false,del:false,search:false,refresh:false})
	.jqGrid('navButtonAdd','#t_list_viewTask',{
	   caption:"创建子计划", 
	   buttonicon:"ui-icon-plus", 
	   onClickButton: function(){ 
	     addRow("list_viewTask","#");
	   }, 
	   position:"last"
	})
	.jqGrid('navButtonAdd','#t_list_viewTask',{
		   caption:"编辑", 
		   buttonicon:"ui-icon-pencil", 
		   onClickButton: function(){ 
		     editRow("list_viewTask","#");
		   }, 
		   position:"last"
		})
	.jqGrid('navButtonAdd','#t_list_viewTask',{ 
	   caption:"删除", 
	   buttonicon:"ui-icon-trash", 
	   onClickButton: function(){ 
	      delRow("list_viewTask","#");
	   }, 
	   position:"last"
	})
	.jqGrid('navButtonAdd','#t_list_viewTask',{
		   caption:"关闭计划", 
		   buttonicon:"ui-icon-document", 
		   onClickButton: function(){ 
		      closeTask("list_viewTask","#");
		   }, 
		   position:"last"
		});
		
		if ($.browser.msie ) {
		$("#list_punishment").jqGrid('setGridWidth',$(".ui-layout-center").width()-30);
		$("#t2").width($(".ui-layout-center").width()-30);
	}
	else{
		$("#list_punishment").jqGrid('setGridWidth',$(".ui-layout-center").width()-245);
	}
	
	
	if ($.browser.msie ) {
		$("#list_viewTask").jqGrid('setGridWidth',$(".ui-layout-center").width()-30);
		$("#t2").width($(".ui-layout-center").width()-30);
	}
	else{
		$("#list_viewTask").jqGrid('setGridWidth',$(".ui-layout-center").width()-245);
	}
	
});


function  closeTask(gridId,ajaxurl){
	//两步操作-1.发送关闭计划的ajax请求2.重新加载jqgrid
	alert("wait for");
	
}
